# drawchart tools/config

import string
import sys

dbuser = "pyhmon"
dbpass = "de723605"
dbhost = "localhost"

def init () :
	global dbuser
	global dbpass
	global dbhost

	try :
		f = open ("db/mysql.conf")
		cont = list (string.split (f.read (), "\n"))
		f.close ()
	except :
		sys.exit ("Cannot open file: db/mysql.conf")
	
	for c in cont :
		if len (c) > 0 :
			if not c[0] == "#" :
				param = string.split (c, "=")
				if param[0] == "host" :
					dbhost = param[1]
				elif param[0] == "user" :
					dbuser = param[1]
				elif param[0] == "pass" :
					dbpass = param[1]

def getDBUser () :
	global dbuser
	return dbuser

def getDBHost () :
	global dbhost
	return dbhost

def getDBPass () :
	global dbpass
	return dbpass

def getValueNum (pluginname) :
	if pluginname == "uptime" :
		return 1
	elif pluginname == "loadavg" :
		return 3
